/*
 *  Copyright (C) void Team 2010 Pedro Batista
 * 
 *  http://code.google.com/p/capacitec
 * 
 *  This file is part of capacitec.
 * 
 *  capacitec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  capacitec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with capacitec.  If not, see <http://www.gnu.org/licenses/>.
 */
package controller;

import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import dao.ErroDao;
import entidades.Erro;

/**
 *
 * @author pedro
 */
@Resource
public class ErroController {

	private ErroDao erroDao;
	private Result result;

	public ErroController(ErroDao erroDao, Result result) {
		this.erroDao = erroDao;
		this.result = result;
	}

	@Get
	@Path("/erro/novo")
	public Exception formulario(Exception ex) {
		return ex;
	}

	@Post
	@Path("/erro")
	public void adiciona(Erro erro, Exception ex) {
		erroDao.salva(erro);
		result.redirectTo(HomeController.class).index();
	}
}
